package com.qffx.moviebase.presenter;

import com.qffx.moviebase.bean.find.FindMovieEntity;
import com.qffx.moviebase.model.FindMovieModel;
import com.qffx.moviebase.model.impl.FindMovieM;
import com.qffx.moviebase.presenter.impl.BasePresenter;
import com.qffx.moviebase.view.impl.FindMovieView;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by lx on 2017/2/10.
 */

public class FindMoviePresenter implements BasePresenter {
    private FindMovieM movieM;
    private FindMovieView view;

    public FindMoviePresenter(FindMovieView view) {
        this.view = view;
        movieM=new FindMovieModel();
    }

    @Override
    public void getData() {

    }
    public void getData(String id){
        Observable<FindMovieEntity> observable=movieM.loadMovie(id);
        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<FindMovieEntity>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(FindMovieEntity entity) {
                    view.setDate(entity);
                    }
                });
    }
}
